package net.sareweb.acab.components.session;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.ArrayBlockingQueue;

import net.sareweb.acab.entity.Avatar;
import net.sareweb.acab.entity.User;
import net.sareweb.acab.util.AcabEvent;

import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Install;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.Startup;
import org.jboss.seam.annotations.intercept.BypassInterceptors;
import org.jboss.seam.log.Log;
import org.jboss.seam.log.LogProvider;
import org.jboss.seam.log.Logging;
import org.jboss.seam.security.Identity;


@Name("acabEvents")
@Scope(ScopeType.APPLICATION)
@Startup
public class AcabEvents {
	@Logger
	private Log log;
	
	private Queue<AcabEvent> lastEvents;
	
	
	public AcabEvents(){
		lastEvents = new ArrayBlockingQueue<AcabEvent>(20);
	}
	
	
	public List<AcabEvent> getLastEvents(){
		return new ArrayList<AcabEvent>(lastEvents);
	}
	
	public void addEvent(AcabEvent acabEvent){
		int size = lastEvents.size();
		if(size==20)lastEvents.remove();
		lastEvents.add(acabEvent);
	}

}